<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <meta name="Content-Type" content="text/html; charset=UTF-8" />
<title>Class: Sass::Exec::Generic</title>
<link rel="stylesheet" href="style.css" tppabs="http://sass-lang.com/docs/yardoc/css/style.css" type="text/css" media="screen" charset="utf-8" />
<link rel="stylesheet" href="common.css" tppabs="http://sass-lang.com/docs/yardoc/css/common.css" type="text/css" media="screen" charset="utf-8" />

<script type="text/javascript" charset="utf-8">
  relpath = '../..';
  if (relpath != '') relpath += '/';
</script>
<script type="text/javascript" charset="utf-8" src="jquery.js" tppabs="http://sass-lang.com/docs/yardoc/js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="app.js" tppabs="http://sass-lang.com/docs/yardoc/js/app.js"></script>

  </head>
  <body>
    <script type="text/javascript" charset="utf-8">
      if (window.top.frames.main) document.body.className = 'frames';
    </script>
    
    <div id="header">
      <div id="menu">
  
    <a href="_index.html" tppabs="http://sass-lang.com/docs/yardoc/_index.html">Index (G)</a> &raquo; 
    <span class='title'><a href="Sass-1.html" tppabs="http://sass-lang.com/docs/yardoc/Sass.html" title="Sass (module)">Sass</a></span> &raquo; <span class='title'><a href="Exec.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/Exec.html" title="Sass::Exec (module)">Exec</a></span>
     &raquo; 
    <span class="title">Generic</span>
  
  
  <div class="noframes"><span class="title">(</span><a href="javascript:if(confirm(%27http://sass-lang.com/docs/yardoc/Sass/Exec/.  \n\nThis file was not retrieved by Teleport Pro, because the server reports that this file cannot be found.  \n\nDo you want to open it from the server?%27))window.location=%27http://sass-lang.com/docs/yardoc/Sass/Exec/.%27" tppabs="http://sass-lang.com/docs/yardoc/Sass/Exec/." target="_top">no frames</a><span class="title">)</span></div>
</div>

      <div id="search">
  <a id="class_list_link" href="#">Class List</a>
  <a id="method_list_link" href="#">Method List</a>
  <a id ="file_list_link" href="#">File List</a>
</div>

      <div class="clear"></div>
    </div>
    
    <iframe id="search_frame"></iframe>
    
    <div id="content"><h1>Class: Sass::Exec::Generic 
  
  
</h1>

<dl class="box">
  
    <dt class="r1">Inherits:</dt>
    <dd class="r1">
      <span class="inheritName">Object</span>
      
        <ul class="fullTree">
          <li>Object</li>
          
            <li class="next">Sass::Exec::Generic</li>
          
        </ul>
        <a href="#" class="inheritanceTree">show all</a>
      
      </dd>
    
  
  
    
  
    
  
  
    <dt class="r2 last">Defined in:</dt>
    <dd class="r2 last">/var/www/sass-pages/.sass/lib/sass/exec.rb</dd>
  
</dl>
<div class="clear"></div>

<h2>Overview</h2><div class="docstring">
  <div class="discussion">
    <p>An abstract class that encapsulates the executable code for all three executables.</p>

  </div>
</div>
<div class="tags">
  
</div><div id="subclasses">
  <h2>Direct Known Subclasses</h2>
  <p class="children"><a href="Sass.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/Exec/Sass.html" title="Sass::Exec::Sass (class)">Sass</a>, <a href="SassConvert.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/Exec/SassConvert.html" title="Sass::Exec::SassConvert (class)">SassConvert</a></p>
</div>

  <h2>Constant Summary</h2>
  



  <h2>Instance Method Summary</h2>

  <ul class="summary">
    
      <li class="protected ">
  <span class="summary_signature">
    
      <a href="#color-instance_method" title="#color (instance method)">- (String) <strong>color</strong>(color, str) </a>
    

    
  </span>
  
  
  <span class="note title protected">protected</span>
  
  

  
    <span class="summary_desc">Wraps the given string in terminal escapes causing it to have the given color.</span>
  
</li>

    
      <li class="protected ">
  <span class="summary_signature">
    
      <a href="#get_line-instance_method" title="#get_line (instance method)">- (String) <strong>get_line</strong>(exception) </a>
    

    
  </span>
  
  
  <span class="note title protected">protected</span>
  
  

  
    <span class="summary_desc">Finds the line of the source template on which an exception was raised.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#initialize-instance_method" title="#initialize (instance method)">- (Generic) <strong>initialize</strong>(args) </a>
    

    
  </span>
  
    <span class="note title constructor">constructor</span>
  
  
  
  
  

  
    <span class="summary_desc">A new instance of Generic.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#parse-instance_method" title="#parse (instance method)">- <strong>parse</strong> </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Parses the command-line arguments and runs the executable.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#parse%21-instance_method" title="#parse! (instance method)">- <strong>parse!</strong> </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Parses the command-line arguments and runs the executable.</span>
  
</li>

    
      <li class="protected ">
  <span class="summary_signature">
    
      <a href="#process_result-instance_method" title="#process_result (instance method)">- <strong>process_result</strong> </a>
    

    
  </span>
  
  
  <span class="note title protected">protected</span>
  
  

  
    <span class="summary_desc">Processes the options set by the command-line arguments.</span>
  
</li>

    
      <li class="protected ">
  <span class="summary_signature">
    
      <a href="#puts-instance_method" title="#puts (instance method)">- <strong>puts</strong>(*args) </a>
    

    
  </span>
  
  
  <span class="note title protected">protected</span>
  
  

  
    <span class="summary_desc">Same as <tt>Kernel.puts</tt>, but doesn&#8217;t print anything if the <code>--quiet</code> option is set.</span>
  
</li>

    
      <li class="protected ">
  <span class="summary_signature">
    
      <a href="#puts_action-instance_method" title="#puts_action (instance method)">- <strong>puts_action</strong>(name, color, arg) </a>
    

    
  </span>
  
  
  <span class="note title protected">protected</span>
  
  

  
    <span class="summary_desc">Prints a status message about performing the given action, colored using the given color (via terminal escapes) if possible.</span>
  
</li>

    
      <li class="protected ">
  <span class="summary_signature">
    
      <a href="#set_opts-instance_method" title="#set_opts (instance method)">- <strong>set_opts</strong>(opts) </a>
    

    
  </span>
  
  
  <span class="note title protected">protected</span>
  
  

  
    <span class="summary_desc">Tells optparse how to parse the arguments available for all executables.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#to_s-instance_method" title="#to_s (instance method)">- (String) <strong>to_s</strong> </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">A description of the executable.</span>
  
</li>

    
  </ul>
<div id="constructor_details" class="method_details_list">
  <h2>Constructor Details</h2>
  
    <div class="method_details first">
  <p class="signature first" id="initialize-instance_method">
  
    - (<tt><a href="" title="Sass::Exec::Generic (class)">Generic</a></tt>) <strong>initialize</strong>(args) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>A new instance of Generic</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>Array&lt;String&gt;</tt>)</span>
      
      
        <span class='name'>args</span>
      
      
      
        &mdash;
        The command-line arguments
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


10
11
12
13</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/exec.rb', line 10</span>

def initialize(args)
  @args = args
  @options = {}
end</pre>
    </td>
  </tr>
</table>
</div>
  
</div>


  <div id="instance_method_details" class="method_details_list">
    <h2>Instance Method Details</h2>
    
    
      <div class="method_details first">
  <p class="signature first" id="color-instance_method">
  
    - (<tt>String</tt>) <strong>color</strong>(color, str)  <span class="extras">(protected)</span>
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Wraps the given string in terminal escapes causing it to have the given color. If terminal esapes aren&#8217;t supported on this platform, just returns the string instead.</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>Symbol</tt>)</span>
      
      
        <span class='name'>color</span>
      
      
      
        &mdash;
        The name of the color to use. Can be <code>:red</code>, <code>:green</code>, or <code>:yellow</code>.
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
        <span class='name'>str</span>
      
      
      
        &mdash;
        The string to wrap in the given color.
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
      
      
        &mdash;
        The wrapped string.
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


148
149
150
151
152
153
154
155
156</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/exec.rb', line 148</span>

def color(color, str)
  raise "[BUG] Unrecognized color #{color}" unless COLORS[color]

  # Almost any real Unix terminal will support color,
  # so we just filter for Windows terms (which don't set TERM)
  # and not-real terminals, which aren't ttys.
  return str if ENV["TERM"].nil? || ENV["TERM"].empty? || !STDOUT.tty?
  return "\e[#{COLORS[color]}m#{str}\e[0m"
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="get_line-instance_method">
  
    - (<tt>String</tt>) <strong>get_line</strong>(exception)  <span class="extras">(protected)</span>
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Finds the line of the source template on which an exception was raised.</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>Exception</tt>)</span>
      
      
        <span class='name'>exception</span>
      
      
      
        &mdash;
        The exception
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
      
      
        &mdash;
        The line number
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


58
59
60
61
62
63</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/exec.rb', line 58</span>

def get_line(exception)
  # SyntaxErrors have weird line reporting
  # when there's trailing whitespace
  return (exception.message.scan(/:(\d+)/).first || ["??"]).first if exception.is_a?(::SyntaxError)
  (exception.backtrace[0].scan(/:(\d+)/).first || ["??"]).first
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="parse-instance_method">
  
    - <strong>parse</strong> 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Parses the command-line arguments and runs the executable. This does not handle exceptions or exit the program.</p>

  </div>
</div>
<div class="tags">
  
  <h3>See Also:</h3>
  <ul class="see">
    
      <li><a href="#parse%21-instance_method" title="Sass::Exec::Generic#parse! (method)">#parse!</a></li>
    
  </ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


37
38
39
40
41
42
43
44</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/exec.rb', line 37</span>

def parse
  @opts = OptionParser.new(&method(:set_opts))
  @opts.parse!(@args)

  process_result

  @options
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="parse!-instance_method">
  
    - <strong>parse!</strong> 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Parses the command-line arguments and runs the executable. Calls <code>Kernel#exit</code> at the end, so it never returns.</p>

  </div>
</div>
<div class="tags">
  
  <h3>See Also:</h3>
  <ul class="see">
    
      <li><a href="#parse-instance_method" title="Sass::Exec::Generic#parse (method)">#parse</a></li>
    
  </ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


19
20
21
22
23
24
25
26
27
28
29
30
31</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/exec.rb', line 19</span>

def parse!
  begin
    parse
  rescue Exception => e
    raise e if @options[:trace] || e.is_a?(SystemExit)

    $stderr.print "#{e.class}: " unless e.class == RuntimeError
    $stderr.puts "#{e.message}"
    $stderr.puts "  Use --trace for backtrace."
    exit 1
  end
  exit 0
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="process_result-instance_method">
  
    - <strong>process_result</strong>  <span class="extras">(protected)</span>
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Processes the options set by the command-line arguments. In particular, sets <code>@options[:input]</code> and <code>@options[:output]</code> to appropriate IO streams.</p>

<p>This is meant to be overridden by subclasses so they can run their respective programs.</p>

  </div>
</div>
<div class="tags">
  
</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


102
103
104
105
106
107
108
109
110
111
112
113
114</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/exec.rb', line 102</span>

def process_result
  input, output = @options[:input], @options[:output]
  args = @args.dup
  input ||=
    begin
      filename = args.shift
      @options[:filename] = filename
      open_file(filename) || $stdin
    end
  output ||= open_file(args.shift, 'w') || $stdout

  @options[:input], @options[:output] = input, output
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="puts-instance_method">
  
    - <strong>puts</strong>(*args)  <span class="extras">(protected)</span>
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Same as <tt>Kernel.puts</tt>, but doesn&#8217;t print anything if the <code>--quiet</code> option is set.</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>Array</tt>)</span>
      
      
        <span class='name'>args</span>
      
      
      
        &mdash;
        Passed on to <tt>Kernel.puts</tt>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


134
135
136
137</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/exec.rb', line 134</span>

def puts(*args)
  return if @options[:for_engine][:quiet]
  Kernel.puts(*args)
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="puts_action-instance_method">
  
    - <strong>puts_action</strong>(name, color, arg)  <span class="extras">(protected)</span>
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Prints a status message about performing the given action, colored using the given color (via terminal escapes) if possible.</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>#to_s</tt>)</span>
      
      
        <span class='name'>name</span>
      
      
      
        &mdash;
        A short name for the action being performed. Shouldn&#8217;t be longer than 11 characters.
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>Symbol</tt>)</span>
      
      
        <span class='name'>color</span>
      
      
      
        &mdash;
        The name of the color to use for this action. Can be <code>:red</code>, <code>:green</code>, or <code>:yellow</code>.
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


125
126
127
128
129</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/exec.rb', line 125</span>

def puts_action(name, color, arg)
  return if @options[:for_engine][:quiet]
  printf color(color, "%11s %s\n"), name, arg
  STDOUT.flush
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="set_opts-instance_method">
  
    - <strong>set_opts</strong>(opts)  <span class="extras">(protected)</span>
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Tells optparse how to parse the arguments available for all executables.</p>

<p>This is meant to be overridden by subclasses so they can add their own options.</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>OptionParser</tt>)</span>
      
      
        <span class='name'>opts</span>
      
      
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/exec.rb', line 72</span>

def set_opts(opts)
  opts.on('-s', '--stdin', :NONE, 'Read input from standard input instead of an input file') do
    @options[:input] = $stdin
  end

  opts.on('--trace', :NONE, 'Show a full traceback on error') do
    @options[:trace] = true
  end

  opts.on('--unix-newlines', 'Use Unix-style newlines in written files.') do
    @options[:unix_newlines] = true if ::Sass::Util.windows?
  end

  opts.on_tail("-?", "-h", "--help", "Show this message") do
    puts opts
    exit
  end

  opts.on_tail("-v", "--version", "Print version") do
    puts("Sass #{::Sass.version[:string]}")
    exit
  end
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="to_s-instance_method">
  
    - (<tt>String</tt>) <strong>to_s</strong> 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>A description of the executable</p>

  </div>
</div>
<div class="tags">
  <h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
      
      
        &mdash;
        A description of the executable
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


47
48
49</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/exec.rb', line 47</span>

def to_s
  @opts.to_s
end</pre>
    </td>
  </tr>
</table>
</div>
    
  </div>

</div>
    
    <div id="footer">
  Generated on Fri Mar  8 20:34:04 2013 by 
  <a href="javascript:if(confirm(%27http://yardoc.org/  \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address.  \n\nDo you want to open it from the server?%27))window.location=%27http://yardoc.org/%27" tppabs="http://yardoc.org/" title="Yay! A Ruby Documentation Tool">yard</a>
  0.5.3 (ruby-1.8.7).
</div>


  <script type="text/javascript">
  var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
  document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
  </script>
  <script type="text/javascript">
  try {
  var pageTracker = _gat._getTracker("UA-535380-8");
  pageTracker._trackPageview();
  } catch(err) {}</script>


  </body>
</html>